/**
 * Author:   .
 * Date:    2017/7/5 0005.
 * File：   原生基类.
 */
import config from '../config'
import * as storage from '../storage'
import {Toast} from 'mint-ui'
class BaseNative {
  getType() {
    return 'BaseNative'
  }

  toast(msg) {
  }

  /***
   * 更新app
   * @param url app下载地址
   * @param downloadSuccess 下载成功的回调
   * @param downloadProgress 下载中的回调
   */
  updateApp(url, downloadSuccess, downloadProgress) {
  }

  /***
   * 微信登录
   * @return {Promise} resolve: obj 用户信息, reject: e, 错误信息
   */
  weixinLogin() {
  }

  /***
   * 微信支付
   * @param param
   */
  weixinPay(param) {
  }
  /***
   * 微信支付-充值到经验值
   * @param param
   */
  weixinPayCharge(param) {
  }
  /***
   * 农行支付
   * @param param
   */
  nonghangPay(param) {
    let paySn = param.paySn
    let key = storage.getKey()
    if (!key || key == '') {
      Toast('请先注册')
      return
    }
    let url = config.website + '/mobile/index.php?act=member_payment&op=abcpay&payment_code=abcpay&key=' + key + '&PaymentType=1&pay_sn=' + paySn
    window.location.href = url
  }

  /***
   * 银联支付
   * @param param
   */
  yinlianPay(param) {
    let key = storage.getKey()
    if (!key || key == '') {
      Toast('请先注册')
      return
    }
    let url = ''
    if (param.type == '2') { // 充值
      url = config.website + '/mobile/api/payment/kuaijiepay/recharge_OrderH5.php?payment_code=kuaijiepay&key=' + key + '&recharge_amount=' + param.amount
    } else { // 支付
      url = config.website + '/mobile/api/payment/kuaijiepay/OrderH5.php?payment_code=kuaijiepay&key=' + key + '&pay_sn=' + param.paySn
    }
    window.location.href = url
  }
  /***
   * 快钱支付
   * @param param
   */
  kuaiqianPay(param) {
    let key = storage.getKey()
    if (!key || key == '') {
      Toast('请先注册')
      return
    }
    let url = ''
    if (param.type == '2') { // 充值
      url = config.website + '/mobile/api/payment/kuaiqian/pay.php?payment_code=kuaiqianpay&key=' + key + '&recharge_amount=' + param.amount
    } else { // 支付
      url = config.website + '/mobile/api/payment/kuaiqian/pay.php?payment_code=kuaiqianpay&key=' + key + '&pay_sn=' + param.paySn
    }
    window.location.href = url
  }

  /**
   * 支付宝支付
   * @param param
   */
  aliPay(param) {
    let key = storage.getKey()
    if (!key || key == '') {
      Toast('请先注册')
      return
    }
    let url = ''
    if (param.type == '2') { // 充值
      url = config.website + '/mobile/api/payment/alipay/wappay/recharge_pay.php?payment_code=alipay&key=' + key + '&recharge_amount=' + param.amount
    } else { // 支付
      url = config.website + '/mobile/api/payment/alipay/wappay/pay.php?payment_code=alipay&key=' + key + '&WIDout_trade_no=' + param.paySn
    }
    window.location.href = url
  }

  /***
   * 微信分享
   * @param url
   */
  weixinShare(url) {
  }
}

export default BaseNative